/**
 */
package ms.unicorn.dsl.unicornDSL.impl;

import java.util.Collection;

import ms.unicorn.dsl.unicornDSL.CallParameter;
import ms.unicorn.dsl.unicornDSL.IdentifiedElement;
import ms.unicorn.dsl.unicornDSL.UnicornDSLPackage;
import ms.unicorn.dsl.unicornDSL.XFeatureCall;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>XFeature Call</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XFeatureCallImpl#getFeature <em>Feature</em>}</li>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XFeatureCallImpl#isNullSafe <em>Null Safe</em>}</li>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XFeatureCallImpl#isOperatorCall <em>Operator Call</em>}</li>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XFeatureCallImpl#getParams <em>Params</em>}</li>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XFeatureCallImpl#isIndexCall <em>Index Call</em>}</li>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XFeatureCallImpl#getFeatureElement <em>Feature Element</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class XFeatureCallImpl extends XExpressionImpl implements XFeatureCall
{
  /**
   * The default value of the '{@link #getFeature() <em>Feature</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFeature()
   * @generated
   * @ordered
   */
  protected static final String FEATURE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getFeature() <em>Feature</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFeature()
   * @generated
   * @ordered
   */
  protected String feature = FEATURE_EDEFAULT;

  /**
   * The default value of the '{@link #isNullSafe() <em>Null Safe</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isNullSafe()
   * @generated
   * @ordered
   */
  protected static final boolean NULL_SAFE_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isNullSafe() <em>Null Safe</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isNullSafe()
   * @generated
   * @ordered
   */
  protected boolean nullSafe = NULL_SAFE_EDEFAULT;

  /**
   * The default value of the '{@link #isOperatorCall() <em>Operator Call</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isOperatorCall()
   * @generated
   * @ordered
   */
  protected static final boolean OPERATOR_CALL_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isOperatorCall() <em>Operator Call</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isOperatorCall()
   * @generated
   * @ordered
   */
  protected boolean operatorCall = OPERATOR_CALL_EDEFAULT;

  /**
   * The cached value of the '{@link #getParams() <em>Params</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParams()
   * @generated
   * @ordered
   */
  protected EList<CallParameter> params;

  /**
   * The default value of the '{@link #isIndexCall() <em>Index Call</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isIndexCall()
   * @generated
   * @ordered
   */
  protected static final boolean INDEX_CALL_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isIndexCall() <em>Index Call</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isIndexCall()
   * @generated
   * @ordered
   */
  protected boolean indexCall = INDEX_CALL_EDEFAULT;

  /**
   * The cached value of the '{@link #getFeatureElement() <em>Feature Element</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFeatureElement()
   * @generated
   * @ordered
   */
  protected IdentifiedElement featureElement;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected XFeatureCallImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return UnicornDSLPackage.Literals.XFEATURE_CALL;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getFeature()
  {
    return feature;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setFeature(String newFeature)
  {
    String oldFeature = feature;
    feature = newFeature;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UnicornDSLPackage.XFEATURE_CALL__FEATURE, oldFeature, feature));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isNullSafe()
  {
    return nullSafe;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setNullSafe(boolean newNullSafe)
  {
    boolean oldNullSafe = nullSafe;
    nullSafe = newNullSafe;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UnicornDSLPackage.XFEATURE_CALL__NULL_SAFE, oldNullSafe, nullSafe));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isOperatorCall()
  {
    return operatorCall;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setOperatorCall(boolean newOperatorCall)
  {
    boolean oldOperatorCall = operatorCall;
    operatorCall = newOperatorCall;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UnicornDSLPackage.XFEATURE_CALL__OPERATOR_CALL, oldOperatorCall, operatorCall));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<CallParameter> getParams()
  {
    if (params == null)
    {
      params = new EObjectContainmentEList<CallParameter>(CallParameter.class, this, UnicornDSLPackage.XFEATURE_CALL__PARAMS);
    }
    return params;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isIndexCall()
  {
    return indexCall;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setIndexCall(boolean newIndexCall)
  {
    boolean oldIndexCall = indexCall;
    indexCall = newIndexCall;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UnicornDSLPackage.XFEATURE_CALL__INDEX_CALL, oldIndexCall, indexCall));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public IdentifiedElement getFeatureElement()
  {
    if (featureElement != null && featureElement.eIsProxy())
    {
      InternalEObject oldFeatureElement = (InternalEObject)featureElement;
      featureElement = (IdentifiedElement)eResolveProxy(oldFeatureElement);
      if (featureElement != oldFeatureElement)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, UnicornDSLPackage.XFEATURE_CALL__FEATURE_ELEMENT, oldFeatureElement, featureElement));
      }
    }
    return featureElement;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public IdentifiedElement basicGetFeatureElement()
  {
    return featureElement;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setFeatureElement(IdentifiedElement newFeatureElement)
  {
    IdentifiedElement oldFeatureElement = featureElement;
    featureElement = newFeatureElement;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UnicornDSLPackage.XFEATURE_CALL__FEATURE_ELEMENT, oldFeatureElement, featureElement));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XFEATURE_CALL__PARAMS:
        return ((InternalEList<?>)getParams()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XFEATURE_CALL__FEATURE:
        return getFeature();
      case UnicornDSLPackage.XFEATURE_CALL__NULL_SAFE:
        return isNullSafe();
      case UnicornDSLPackage.XFEATURE_CALL__OPERATOR_CALL:
        return isOperatorCall();
      case UnicornDSLPackage.XFEATURE_CALL__PARAMS:
        return getParams();
      case UnicornDSLPackage.XFEATURE_CALL__INDEX_CALL:
        return isIndexCall();
      case UnicornDSLPackage.XFEATURE_CALL__FEATURE_ELEMENT:
        if (resolve) return getFeatureElement();
        return basicGetFeatureElement();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XFEATURE_CALL__FEATURE:
        setFeature((String)newValue);
        return;
      case UnicornDSLPackage.XFEATURE_CALL__NULL_SAFE:
        setNullSafe((Boolean)newValue);
        return;
      case UnicornDSLPackage.XFEATURE_CALL__OPERATOR_CALL:
        setOperatorCall((Boolean)newValue);
        return;
      case UnicornDSLPackage.XFEATURE_CALL__PARAMS:
        getParams().clear();
        getParams().addAll((Collection<? extends CallParameter>)newValue);
        return;
      case UnicornDSLPackage.XFEATURE_CALL__INDEX_CALL:
        setIndexCall((Boolean)newValue);
        return;
      case UnicornDSLPackage.XFEATURE_CALL__FEATURE_ELEMENT:
        setFeatureElement((IdentifiedElement)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XFEATURE_CALL__FEATURE:
        setFeature(FEATURE_EDEFAULT);
        return;
      case UnicornDSLPackage.XFEATURE_CALL__NULL_SAFE:
        setNullSafe(NULL_SAFE_EDEFAULT);
        return;
      case UnicornDSLPackage.XFEATURE_CALL__OPERATOR_CALL:
        setOperatorCall(OPERATOR_CALL_EDEFAULT);
        return;
      case UnicornDSLPackage.XFEATURE_CALL__PARAMS:
        getParams().clear();
        return;
      case UnicornDSLPackage.XFEATURE_CALL__INDEX_CALL:
        setIndexCall(INDEX_CALL_EDEFAULT);
        return;
      case UnicornDSLPackage.XFEATURE_CALL__FEATURE_ELEMENT:
        setFeatureElement((IdentifiedElement)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XFEATURE_CALL__FEATURE:
        return FEATURE_EDEFAULT == null ? feature != null : !FEATURE_EDEFAULT.equals(feature);
      case UnicornDSLPackage.XFEATURE_CALL__NULL_SAFE:
        return nullSafe != NULL_SAFE_EDEFAULT;
      case UnicornDSLPackage.XFEATURE_CALL__OPERATOR_CALL:
        return operatorCall != OPERATOR_CALL_EDEFAULT;
      case UnicornDSLPackage.XFEATURE_CALL__PARAMS:
        return params != null && !params.isEmpty();
      case UnicornDSLPackage.XFEATURE_CALL__INDEX_CALL:
        return indexCall != INDEX_CALL_EDEFAULT;
      case UnicornDSLPackage.XFEATURE_CALL__FEATURE_ELEMENT:
        return featureElement != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (feature: ");
    result.append(feature);
    result.append(", nullSafe: ");
    result.append(nullSafe);
    result.append(", operatorCall: ");
    result.append(operatorCall);
    result.append(", indexCall: ");
    result.append(indexCall);
    result.append(')');
    return result.toString();
  }

} //XFeatureCallImpl
